package com.campus_information_portal.dao;

import com.campus_information_portal.entity.PartyActivityConditions;
import org.apache.ibatis.jdbc.SQL;
/**
 * @author 20155880 房雁颖
 * @description 党支部活动动态查询
 * @project_name
 * @package
 * @create 2018-05-13 20:48
 **/
public class PartyActivitySqlProvider {
    public String queryPartyActivityByConditions(PartyActivityConditions partyActivityConditions) {
        StringBuilder sql = new StringBuilder("select * from party_activity  where party_organization_num=#{partyOrganizationNum} and 1=1");
        if (partyActivityConditions.getPartyActivityName()!=null){
            sql.append(" and party_activity_name like CONCAT(CONCAT('%',#{partyActivityName}),'%')");
        }
        if ((partyActivityConditions.getPartyActivityStartTime()!=null)){
            sql.append(" and party_activity_time>#{partyActivityStartTime}");
        }
        if (partyActivityConditions.getPartyActivityEndTime()!=null){
            sql.append(" and party_activity_time<#{partyActivityEndTime}");
        }
        System.out.println(sql.toString());
        return sql.toString();
    }

    public String queryPartyActivityByConditionsByCache(PartyActivityConditions partyActivityConditions) {
        StringBuilder sql = new StringBuilder("select * from party_activity  where party_organization_num=#{partyOrganizationNum} and 1=1");
        if (partyActivityConditions.getPartyActivityName()!=null){
            sql.append(" and party_activity_name like CONCAT(CONCAT('%',#{partyActivityName}),'%')");
        }
        if ((partyActivityConditions.getPartyActivityStartTime()!=null)){
            sql.append(" and party_activity_time>#{partyActivityStartTime}");
        }
        if (partyActivityConditions.getPartyActivityEndTime()!=null){
            sql.append(" and party_activity_time<#{partyActivityEndTime}");
        }
        System.out.println(sql.toString());
        return sql.toString();
    }

//    public String queryPartyActivityTempByConditions(PartyActivityConditions partyActivityConditions) {
//        StringBuilder sql = new StringBuilder("select * from party_activity_temp  where party_organization_num=#{partyOrganizationNum} and 1=1");
//        if (partyActivityConditions.getPartyActivityName()!=null){
//            sql.append(" and party_activity_name like CONCAT(CONCAT('%',#{partyActivityName}),'%')");
//        }
//        if ((partyActivityConditions.getPartyActivityStartTime()!=null)){
//            sql.append(" and party_activity_time>#{partyActivityStartTime}");
//        }
//        if (partyActivityConditions.getPartyActivityEndTime()!=null){
//            sql.append(" and party_activity_time<#{partyActivityEndTime}");
//        }
//        System.out.println(sql.toString());
//        return sql.toString();
//    }
}
